package com.example.jeong.yuejian10.Fragment;



import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.jeong.yuejian10.Adapter.ProCourseListAdapter;
import com.example.jeong.yuejian10.Bean.ProBean;
import com.example.jeong.yuejian10.Listener.RetrofitListener;
import com.example.jeong.yuejian10.Model.ProModel;
import com.example.jeong.yuejian10.R;

import java.util.List;

//大师详情页 大师课堂
public class ProCourseFragment extends Fragment implements RetrofitListener<List<ProBean>> {

    private RecyclerView recyclerView;
    private View view = null;
    private int pmId;
    private ProCourseListAdapter proCourseListAdapter;



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment
        view =  inflater.inflate(R.layout.fragment_procourse, container, false);
        // pmId=getIntent().getIntExtra("pm_id",-1);
        initViews();
        getData();
        return view;

    }

    private void initViews(){
        recyclerView = (RecyclerView) view.findViewById(R.id.rV_ProCourse);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }
    private void getData(){
        Bundle bundle=getArguments();
        int pmId=bundle.getInt("pm_id");
        ProModel proModel = new ProModel();
        proModel.getPcList(pmId,this);
    }

    @Override
    public void onSuccess(List<ProBean> proBeen) {
        proCourseListAdapter = new ProCourseListAdapter(ProCourseFragment.this.getActivity(),proBeen);
        recyclerView.setAdapter(proCourseListAdapter);
    }

    @Override
    public void onFail() {

    }
}
